// run: $exec < input
#include <iostream>
#include <utility>

int gcd(int x, int y)
{
	return ((!y) ? (x) : (gcd(y, x % y)));
}

struct time_type
{
	int hour, min, sec;
};

std::istream & operator>>(std::istream & is, time_type & a)
{
	char ch;
	is >> a.hour >> ch >> a.min >> ch >> a.sec;
	return is;
}

int const maxn = 86400; //86400
int one_day[maxn + 44][3]; // 0:sec, 1:min, 2:hour
int rotate_ps[3] = {6 * 360, 36, 3};
time_type da;

void init_one_day()
{
	one_day[0][0] = one_day[0][1] = one_day[0][2] = 0;
	for (int i = 1; i < maxn + 4; i++) {
		for (int j = 0; j < 3; j++) {
			one_day[i][j] = one_day[i-1][j] + rotate_ps[j];
			if (one_day[i][j] > 360 * 360) one_day[i][j] -= 360 * 360;
		}
	}
}

void print(int x)
{
	if (!(x % 360)) {
		std::cout << x / 360 << ' ';
	} else {
		int t = gcd(360, x);
		int up = x/t, down = 360/t;
		std::cout << up << '/' << down << ' ';
	}
}

int mo = 360 * 360;

void calc(int x)
{
	int a1 = std::abs(one_day[x][2] - one_day[x][1]);
	if (a1 > mo/2) a1 = mo - a1;
	int a2 = std::abs(one_day[x][2] - one_day[x][0]);
	if (a2 > mo/2) a2 = mo - a2;
	int a3 = std::abs(one_day[x][1] - one_day[x][0]);
	if (a3 > mo/2) a3 = mo - a3;
	print(a1); print(a2); print(a3); std::cout << '\n';
}

int main()
{
	std::ios::sync_with_stdio(false);
	init_one_day();
	int T;
	std::cin >> T;
	while (T--) {
		std::cin >> da;
		calc(da.hour * 3600 + da.min * 60 + da.sec);
	}
}

